snapshot: Add _push_collect() and _pop_collect()
authorTimm Bäder <mail@baedert.org>
Fri, 31 Jan 2020 07:05:34 +0000 (08:05 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 7 Feb 2020 18:16:32 +0000 (13:16 -0500)
These will replace the previous gtk_snapshot_new_with_parent(), which
allocated an entirely new GObject just to push()/pop() some state. This
is already a problem but will be more important in the future as we
start using this more.

gtk/gtksnapshot.c
gtk/gtksnapshotprivate.h

index 5654e0abbcde479748069a988c347c08c3cef4de..1804ffb9c2c9af534d030cd047a125f045d88480 100644 (file)
@@ -1138,6 +1138,30 @@ gtk_snapshot_pop_internal (GtkSnapshot *snapshot)
   return gtk_snapshot_pop_one (snapshot);
 }
 
+/**
+ * gtk_snapshot_push_collect:
+ *
+ * PRIVATE.
+ *
+ * Puhses state so a later pop_collect call can collect all nodes
+ * appended until that point.
+ */
+void
+gtk_snapshot_push_collect (GtkSnapshot *snapshot)
+{
+  gtk_snapshot_push_state (snapshot,
+                           NULL,
+                           gtk_snapshot_collect_default);
+}
+
+GskRenderNode *
+gtk_snapshot_pop_collect (GtkSnapshot *snapshot)
+{
+  GskRenderNode *result = gtk_snapshot_pop_internal (snapshot);
+
+  return result;
+}
+
 /**
  * gtk_snapshot_to_node:
  * @snapshot: a #GtkSnapshot
index e02531e1a5167a4fc7f8fce27bbe2518601d949e..7317b4ad59a0f27b49a22061950d7869475f4210 100644 (file)
@@ -104,6 +104,10 @@ void                    gtk_snapshot_append_text                (GtkSnapshot
                                                                  const GdkRGBA          *color,
                                                                  float                   x,
                                                                  float                   y);
+
+void                    gtk_snapshot_push_collect               (GtkSnapshot            *snapshot);
+GskRenderNode *         gtk_snapshot_pop_collect                (GtkSnapshot            *snapshot);
+
 G_END_DECLS
 
 #endif /* __GTK_SNAPSHOT_PRIVATE_H__ */